package com.nttuan.model.entity;

import android.util.Log;

import com.nttuan.util.Support;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by NT Tuan on 10/20/2014.
 */
public class Task {
    private static final String TAG = "task entity";
    public static final String TABLE_NAME = "task";

    public static final String TASK_ID = "taskId";
    public static final String TASK_NAME = "taskName";
    public static final String DATE_START = "start";
    public static final String DATE_END = "end";
    public static final String DURING = "during";
    public static final String REMIND = "remind";
    public static final String LEVEL = "level";
    public static final String REPEAT = "repeat";
    public static final String NOTE = "note";
    public static final String IS_ACTIVE = "isActive";
    public static final String TIME_ZONE = "timeZone";
    public static final String PUBLIC_ID = "publicId";

    private int taskId;
    private String taskName;
    private Date start;
    private Date end;
    private int during;
    private int remind;
    private int level;
    private String repeat;
    private String note;
    private String timeZone;
    private boolean isActive;
    private Location location;
    private Category category;
    private int publicId;

    public static JSONObject jTask(Task task){
        try {
            JSONObject object = new JSONObject();
            object.put(TASK_NAME, task.getTaskName());
            object.put(DATE_START, Support.toString(task.getStart()));
            object.put(DATE_END, Support.toString(task.getEnd()));
            object.put(DURING, task.getDuring());
            object.put(REMIND, task.getRemind());
            object.put(LEVEL, task.getLevel());
            object.put(REPEAT, task.getRepeat());
            object.put(TIME_ZONE, task.getTimeZone());
            object.put(PUBLIC_ID,task.getPublicId());
            JSONObject result = new JSONObject();
            result.put(TABLE_NAME, object);
            return result;
        }catch (Exception e){
            Log.d(TAG, "jTask:" + e.toString());
        }
        return null;
    }

    private List<Contact> listContact;

    public  Task(){}
    public Task(int taskId,String taskName, Date start, int during){
        this.taskId = taskId;
        this.taskName = taskName;
        this.start = start;
        this.during = during;
    }
    public Task(int taskId, String taskName, Date start, int during, int remind, int level, String repeat, String note, boolean isActive) {
        this.taskId = taskId;
        this.taskName = taskName;
        this.start = start;
        this.during = during;
        this.remind = remind;
        this.level = level;
        this.repeat = repeat;
        this.note = note;
        this.isActive = isActive;
    }

    public Task(int taskId) {
        this.taskId = taskId;
    }

    public int getTaskId() {
        return taskId;
    }

    public void setTaskId(int taskId) {
        this.taskId = taskId;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public Date getStart() {
        return start;
    }

    public void setStart(Date start) {
        this.start = start;
    }

    public int getDuring() {
        return during;
    }

    public void setDuring(int during) {
        this.during = during;
    }

    public int getRemind() {
        return remind;
    }

    public void setRemind(int remind) {
        this.remind = remind;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public String getRepeat() {
        return repeat;
    }

    public void setRepeat(String repeat) {
        this.repeat = repeat;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public boolean isActive() {
        return isActive;
    }

    public void setActive(boolean isActive) {
        this.isActive = isActive;
    }
    public Location getLocation() {
        return location;
    }

    public String getTimeZone() {
        return timeZone;
    }

    public void setTimeZone(String timeZone) {
        this.timeZone = timeZone;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public List<Contact> getListContact() {
        if(listContact == null)
            this.listContact = new ArrayList<Contact>();
        return listContact;
    }

    public Date getEnd() {
        return end;
    }

    public void setEnd(Date end) {
        this.end = end;
    }

    public void setListContact(List<Contact> listContact) {

        this.listContact = listContact;
    }

    public int getPublicId() {
        return publicId;
    }

    public void setPublicId(int publicId) {
        this.publicId = publicId;
    }
}
